<template>
  <div class="nav">
    <div
      v-for="(menu, i) in menus"
      :key="i"
      v-if="menu.show"
      @click="move(menu)"
      :class="{ 'active':activeIndex == menu.index-1 }"
      v-text="menu.text"
    ></div>
  </div>
</template>

<script>
export default {
  props: ["activeIndex", "isFavorite"],
  data() {
    return {
      menus: [
        {
          text: "方案书封面",
          index: 1,
          show: true
        },
        {
          text: "全景图欣赏",
          index: 2,
          show: true
        },
        {
          text: "效果图欣赏",
          index: 3,
          show: true
        },
        {
          text: "立即预约",
          index: 4,
          show: true
        },
        {
          text: this.isFavorite ? "已收藏" : "收藏",
          index: 5,
          show: true
        }
      ]
    };
  },
  methods: {
    move(menu) {
      let index = menu.index;
      if (index == 4) {
        this.$emit("showDialog");
      } else if (index == 5) {
        this.$emit("favorite");
      } else {
        this.$emit("update:activeIndex", index);
        $.fn.fullpage.moveTo(index);
      }
      this.$emit("update:showNav", false);
    }
  },

  mounted() {
    // this.activeIndex = Number(this.$route.hash.substr(5)) + 1;
  }
};
</script>

<style lang="less">
.nav {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 436px;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  padding-top: 20px;
  padding-bottom: 40px;
  z-index: 15;
  > div {
    margin: 0 auto;
    width: 350px;
    height: 56px;
    border-radius: 56px;
    line-height: 48px;
    font-size: 28px;
    color: #ffae34;
    border: 4px solid #ffc773;
    margin-top: 20px;
    box-sizing: border-box;
  }

  .active {
    background: #ffae34;
    color: #fff;
  }
}
</style>